FROM python:3.7-slim
ENV PYTHONUNBUFFERED 1

RUN mkdir /code
WORKDIR /code

COPY requirements.txt /code/

RUN pip install --upgrade pip setuptools wheel
RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt || \
    pip install -r requirements.txt

COPY . /code/

ENV LANG=zh_CN.UTF-8
ENV LC_ALL=zh_CN.UTF-8

VOLUME /code/static
VOLUME /code/media

RUN python manage.py collectstatic --noinput
RUN python manage.py migrate
RUN python manage.py loaddata --app idcops init_data.json